package com.duoduo.admin.entity;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Entity
@Getter
@Setter
@EntityListeners(AuditingEntityListener.class)
public class SysPost implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5801433527286853068L;
	
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
     /**
	 * id
	 */
	private Long id;
     /**
	 * 岗位code
	 */
	private String postCode;
	
     /**
	 * 岗位名称
	 */
	private String postName;
     /**
	 * 排序
	 */
	private Integer postSort;
     /**
	 * 删除标识
	 */
	private Boolean delFlag;
     /**
	 * 创建人
	 */
    @CreatedBy
	private String createBy;
     /**
	 * 创建时间
	 */
    @CreatedDate
	private LocalDateTime createTime;
     /**
	 * 修改人
	 */
    @LastModifiedBy
	private String updateBy;
     /**
	 * 更新时间
	 */
    @LastModifiedDate
	private LocalDateTime updateTime;
    
    @ManyToOne
    @JoinColumn(name = "parent_id")
    private SysPost parent;
    
    @OneToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY)
    @BatchSize(size = 30)
    @Fetch(value = FetchMode.SELECT)
    @JoinColumn(name = "parent_id")
    @ToString.Exclude
    private List<SysPost> children;

}
